/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufpr.tads.suck.model;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author G0006185
 */
public class ConnectionFactory {

    public static Connection getConnection() throws FileNotFoundException, IOException, ClassNotFoundException, SQLException {
        Properties prop = ConnectionFactory.getProp();
        String drive =  prop.getProperty("db.driver");
        String url =  prop.getProperty("db.url");
        String user =  prop.getProperty("db.user");
        String pwd =  prop.getProperty("db.pwd");
        Class.forName(drive);
        return DriverManager.getConnection(url, user, pwd);
    }

    private static Properties getProp() throws FileNotFoundException, IOException{
        Properties prop = new Properties();
        FileInputStream file = new FileInputStream("/home/julio/NetBeansProjects/SUHCK/src/java/br/ufpr/tads/suck/model/db.properties");
        prop.load(file);
        return prop;
    }
}
